package router

import (
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
	"shop_webs/userop_web/api/address"
	"shop_webs/userop_web/api/message"
	"shop_webs/userop_web/api/user_fav"
	"shop_webs/userop_web/middlewares"
)

func InitUseropRouter(Router *gin.RouterGroup) {
	zap.S().Info("配置收藏相关的url")
	UserfavsRouter := Router.Group("userfavs").Use(middlewares.SetUserId())
	{
		UserfavsRouter.GET("", user_fav.List)          //收藏列表页
		UserfavsRouter.GET("/:id", user_fav.Detail)    //收藏商品详细
		UserfavsRouter.POST("", user_fav.New)          //新建收藏
		UserfavsRouter.DELETE("/:id", user_fav.Delete) //删除收藏
	}

	zap.S().Info("配置收货地址相关的url")
	AddressRouter := Router.Group("address").Use(middlewares.SetUserId())
	{
		AddressRouter.GET("", address.List)          //收货地址列表页
		AddressRouter.POST("", address.New)          //新建收货地址
		AddressRouter.PUT("/:id", address.Update)    //修改收货地址
		AddressRouter.DELETE("/:id", address.Delete) //删除收货地址
	}

	zap.S().Info("配置留言相关的url")
	MessageRouter := Router.Group("message").Use(middlewares.SetUserId())
	{
		MessageRouter.GET("", message.List) //留言列表页
		MessageRouter.POST("", message.New) //新建留言
	}
}
